// 小程序入口文件
App({
  onLaunch() {
    const that = this
    // 检查登录状态
    const token = wx.getStorageSync('token');
    that.globalData.token = token || '';
    that.globalData.isLoggedIn = !!token;
    
    wx.checkSession({
      success() {
        if (!token) {
          wx.reLaunch({
            url: '/pages/login/login'
          })
        }
      },
      fail() {
        wx.setStorageSync('token', '')
        wx.reLaunch({
          url: '/pages/login/login'
        })
      }
    })
  },
  globalData: {
    userInfo: null,
    isLoggedIn: false,
    authCode: ''
  }
})